package com.example.demo.Mapper;

import com.example.demo.Entity.Skill;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SkillMapper {
    @Select("SELECT * FROM skills_certificates WHERE person_id = #{userId}")
    List<Skill> findByUserId(Long userId);

    // 批量更新技能证书
    void batchUpdateSkills(@Param("skills") List<Skill> skills);

    // 删除指定用户的所有技能证书
    @Delete("DELETE FROM skills_certificates WHERE person_id = #{userId}")
    int deleteByUserId(Long userId);

    // 删除单个技能证书
    @Delete("DELETE FROM skills_certificates WHERE id = #{id}")
    int deleteById(Long id);

    // 插入技能证书
    @Insert("INSERT INTO skills_certificates(person_id, skill_name, certificate_name, obtain_date, score) " +
            "VALUES(#{person_id}, #{skill_name}, #{certificate_name}, #{obtain_date}, #{score})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Skill skill);
}
